﻿using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using EcoSystem.Permissions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Identity;

namespace EcoSystem;

/// <summary>
/// 系统用户管理
/// </summary>
[Area(EcoSystemRemoteServiceConsts.ModuleName)]
[RemoteService(Name = EcoSystemRemoteServiceConsts.RemoteServiceName)]
[Route("api/Platform/systemRole")]
public class SystemRoleController : EcoSystemController, ISystemRoleAppService
{
    private readonly ISystemRoleAppService _service;
    public SystemRoleController(ISystemRoleAppService service)
    {
        _service = service;
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    /// <exception cref="NotImplementedException"></exception>
    [HttpPost]
    public async Task<IdentityRoleDto> CreateAsync(IdentityRoleDto input)
    {
        return await _service.CreateAsync(input);
    }

    /// <summary>
    /// 不分页查询
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    /// <exception cref="NotImplementedException"></exception>
    [HttpGet]
    [Route("all")]
    public async Task<ListResultDto<IdentityRoleDto>> GetAllListAsync(GetIdentityRolesInput input)
    {
        return await _service.GetAllListAsync(input);
    }

    /// <summary>
    ///  获取详情
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    /// <exception cref="NotImplementedException"></exception>
    [HttpGet]
    [Route("{id}")]
    public async Task<IdentityRoleDto> GetAsync(Guid id)
    {
        return await _service.GetAsync(id);
    }

    /// <summary>
    /// 分页查询
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    /// <exception cref="NotImplementedException"></exception>
    [HttpGet]
    public async Task<PagedResultDto<IdentityRoleDto>> GetListAsync(GetIdentityRolesInput input)
    {
        return await _service.GetListAsync(input);
    }

    /// <summary>
    /// 修改
    /// </summary>
    /// <param name="id"></param>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpPut]
    [Route("{id}")]
    public async Task<IdentityRoleDto> UpdateAsync(Guid id, IdentityRoleDto input)
    {
        return await _service.UpdateAsync(id, input);
    }
}
